package com.angel.email.response;

import java.util.Collection;

import com.angel.email.dtos.EmailMessageDTO;

/**
 *
 * @author William
 *
 */
public class EmailMessagesResponse {

	private Collection<EmailMessageDTO> messages;
	private Long totalSize = 0L;
	private Long countMessages;

	public EmailMessagesResponse(Collection<EmailMessageDTO> messages){
		super();
		this.messages = messages;
		this.countMessages = Long.valueOf(messages.size());
		this.calculateTotalSize();
	}

	private void calculateTotalSize() {
		for(EmailMessageDTO em: messages){
			this.totalSize += em.getSize();
		}
	}

	/**
	 * @return the messages
	 */
	public Collection<EmailMessageDTO> getMessages() {
		return messages;
	}

	public Long getTotalSize(){
		return this.totalSize;
	}

	/**
	 * @return the countMessages
	 */
	public Long getCountMessages() {
		return countMessages;
	}

	public Boolean hasMoreMessagesThan(Long countMessage){
		return this.getCountMessages().longValue() > countMessage.longValue();
	}

	public Boolean hasLessMessagesThan(Long countMessage){
		return this.getCountMessages().longValue() < countMessage.longValue();
	}

	public Boolean hasCountMessagesEquals(Long countMessage){
		return this.getCountMessages().longValue() == countMessage.longValue();
	}
}
